<?php
namespace CCP;
/*
 *  Copyright (c) 2014 The CCP project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a Beijing Speedtong Information Technology Co.,Ltd license
 *  that can be found in the LICENSE file in the root of the web site.
 *
 *   http://www.yuntongxun.com
 *
 *  An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

class stdClass{

//主帐号
public $accountSid= '8aaf07085d7cf73f015d9b57c1420919';

//主帐号Token
public $accountToken= 'dedf14f1008142928148f66bb0fd326a';

//应用Id
public $appId='8aaf07085d7cf73f015d9b57c18c091d';

//请求地址，格式如下，不需要写https://
public $serverIP='app.cloopen.com';

//请求端口 
public $serverPort='8883';

//REST版本号
public $softVersion='2013-12-26';


/**
  * 发送模板短信
  * @param to 手机号码集合,用英文逗号分开
  * @param datas 内容数据 格式为数组 例如：array('Marry','Alon')，如不需替换请填 null
  * @param $tempId 模板Id   1
  */       
function sendTemplateSMS($to,$datas,$tempId)
{
     // 初始化REST SDK
     
     $rest = new REST($this->serverIP,$this->serverPort,$this->softVersion);
     $rest->setAccount($this->accountSid,$this->accountToken);
     $rest->setAppId($this->appId);
    
     // 发送模板短信
     echo "Sending TemplateSMS to $to <br/>";
     $result = $rest->sendTemplateSMS($to,$datas,$tempId);
     if($result == NULL ) {
         echo "result error!";
         // break;
     }
     if($result->statusCode!=0) {
         echo "error code :" . $result->statusCode . "<br>";
         echo "error msg :" . $result->statusMsg . "<br>";
         //TODO 添加错误处理逻辑
     }else{
         echo "Sendind TemplateSMS success!<br/>";
         // 获取返回信息
         $smsmessage = $result->TemplateSMS;
         echo "dateCreated:".$smsmessage->dateCreated."<br/>";
         echo "smsMessageSid:".$smsmessage->smsMessageSid."<br/>";
         //TODO 添加成功处理逻辑
     }
}

//Demo调用,参数填入正确后，放开注释可以调用 
//sendTemplateSMS("手机号码","内容数据","模板Id");

}

?>
